package com.ezjie.ielts.util;

import java.text.DecimalFormat;

import android.R.integer;

/**
 * b kb M G 单位转换
 * @author renyangyang
 *
 */
public class SizeUtil {

	private static final DecimalFormat df = new DecimalFormat("0.00");//2个小数位的 double M
	private static final double Kb = 1024;//  1kb
	private static final double Mb = 1048576;//  1Mb
	private static final double Gb = 1073741824;//  1G
	/**
	 * byte  转化为 Mb
	 * @param bytes
	 * @return
	 */
	public static String byte2Mb(long bytes){
		return df.format(((double)bytes)/Mb);
	}
	/**
	 * 
	 * @param totalSize
	 * @param percent
	 * @return
	 */
	public static long getSizeByPercent(long totalSize,long percent){
		return totalSize*percent/100;
	}
	
}
